package pdd;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.PriorityQueue;

public class Main1 {

    public static void main(String[] args) throws Exception{
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        String s = buf.readLine();
        String[] ss;
        int T = Integer.parseInt(s);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < T; i++){
            int res = 0;

            s = buf.readLine();
            int N = Integer.parseInt(s);
            for (int j = 0; j < N; j++){
                s = buf.readLine();
                ss = s.split(" ");
                int score = Integer.parseInt(ss[0]);
                int endDay = Integer.parseInt(ss[1]);
            }

            sb.append(res).append("\n");
        }
        System.out.print(sb.toString());
    }

    public void dfs(int[] scores, int[] endDays, boolean visited, int day){

    }
}
